import java.io.IOException;
import java.util.Properties;

import com.sun.org.apache.bcel.internal.generic.ALOAD;

import br.ufmg.vod.wbr.algorithims.bfs.FastBFS;
import br.ufmg.vod.wbr.graphs.FastDirectedGraph;
import br.ufmg.vod.wbr.graphs.FastGraph;
import br.ufmg.vod.wbr.graphs.IDXGraphLoader;


public class MyShortestPathDirected {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		Properties props = new Properties(); 
		props.load(ClassLoader.getSystemResourceAsStream("collection.properties"));
		String inLinkIdx = props.getProperty("collection.path")+props.getProperty("inlinks.idx");
		String inLink = props.getProperty("collection.path")+props.getProperty("inlinks");
		String outLinkIdx = props.getProperty("collection.path")+props.getProperty("outlinks.idx");
		String outLink = props.getProperty("collection.path")+props.getProperty("outlinks");
		boolean sample = Boolean.valueOf(props.getProperty("sample"));
		int sampleSize = Integer.valueOf(props.getProperty("sample.size"));
		System.out.println(props);
		
		
		long start = System.currentTimeMillis();
		FastDirectedGraph directedGraph = new IDXGraphLoader(inLinkIdx, inLink, outLinkIdx, outLink, sample, sampleSize).loadGraph();
		System.err.printf("GraphContructor: %.3f seconds.\n",(System.currentTimeMillis()-start)/1000f);
		
		
		FastBFS algorithm = new FastBFS(directedGraph);
		for (int u = 0; u < directedGraph.getNumVertex(); u++) {
			algorithm.bfsSingleVertex(u);
			algorithm.clear();
			System.err.printf("FastBFS( %s ): %.3f seconds.\n", u, (System.currentTimeMillis()-start)/1000f);
			//DEBUG
//				if ( u%1024 == 0 ) System.err.printf("FastBFS( %s ): %.3f seconds.\n", u, (System.currentTimeMillis()-start)/1000f);
		}
		System.err.printf("FastBFS( directedGraph ): %.3f seconds.\n", (System.currentTimeMillis()-start)/1000f);
		
		
	}

}
